package com.example.jyapplication.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.jyapplication.R;

public class PersonActivity extends AppCompatActivity implements View.OnClickListener {
    TextView tvUpdate,tvUserName,tvExit;
    ImageView ivMyBack;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_person);
        initView();
        getData();
    }

    private void getData() {

        SharedPreferences sp = this.getSharedPreferences("info",0);
        String userName = sp.getString("userName","");
        tvUserName.setText("用户："+userName);
    }

    private void initView() {
        tvUserName = findViewById(R.id.tv_person_name);
        tvUpdate = findViewById(R.id.tv_person_update);
        tvUpdate.setOnClickListener(this);
        tvExit = findViewById(R.id.tv_exit);
        tvExit.setOnClickListener(this);
        ivMyBack = findViewById(R.id.iv_person_back);
        ivMyBack.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_person_update:
                Intent intent2 = new Intent(this,PersonUpdateActivity.class);
                startActivity(intent2);
                break;
            case R.id.tv_exit:
                Intent intent3 = new Intent(this,LoginActivity.class);
                startActivity(intent3);
                break;
            case R.id.iv_person_back:
                Intent intent4 = new Intent(this,FoodListActivity.class);
                startActivity(intent4);
                break;
        }
    }
}